public class SudoCommand {
    public static void sudoCommand(PersonList personList) {

        boolean over = false;
        String op;// 储存单行

        while (!over) {
            op = MyUtil.in.nextLine();
            String[] command = op.split("\\s+");// 将一行字符串分割为指令+多个参数
            switch (command[0]) {
            case "sncu":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.newPerson(command[1], command[2], command[3], command[4], MyUtil.SUDO_CUSTOMER);
                }
                break;
            case "snwa":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.newPerson(command[1], command[2], command[3], command[4], MyUtil.SUDO_WAITER);
                }
                break;
            case "snco":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.newPerson(command[1], command[2], command[3], command[4], MyUtil.SUDO_COOK);
                }
                break;
            case "dcu":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.deletePerson(command[1], MyUtil.SUDO_CUSTOMER);
                }
                break;
            case "dwa":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.deletePerson(command[1], MyUtil.SUDO_WAITER);
                }
                break;
            case "dco":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.deletePerson(command[1], MyUtil.SUDO_COOK);
                }
                break;
            case "pp":
                if (MyUtil.checkSudoCommand(command, 0)) {
                    personList.printAll();
                }
                break;
            case "SQ":
                over = true;
                System.out.println(MyUtil.SUDO_QUIT);
                break;
            default:
                System.out.println("Call sudo method illegal");
                break;
            }

        }
    }
}
